package test02;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class Test02 {
    public static void main(String[] args) throws ParseException {
        //1.输入自己入职的年份
        Scanner sc = new Scanner(System.in);
        System.out.println("请你输入入职年份:xxxx年xx月xx日");
        String year = sc.next();
        //2.根据入职的年份格式化为Date对象
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
        Date date = sdf.parse(year);
        //3.获取Date对象对应的毫秒值
        long start = date.getTime();
        //4.获取现在的毫秒值
        long end = System.currentTimeMillis();
        //5.现在的毫秒值-入职年份对应的毫秒值
        long result = end - start;
        //6.结果/1000/60/60/24计算出具体的天数
        long day = result / 1000 / 60 / 60 / 24;
        //7.具体的入职总天数/365
        long result01 = day / 365;
        System.out.println("您入职了"+result01+"年");
    }
}
